cmake_minimum_required(VERSION 3.10)  # 建议使用最新稳定版

# ----------------------
# 基础配置
# ----------------------
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# 定义路径变量（明确项目结构）
set(PROJECT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(PROJECT_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")



# ----------------------
# 静态库定义
# ----------------------
set(AI_COMMON_LIBRARY ${PROJECT_NAME}_common_static)
add_library(${AI_COMMON_LIBRARY} STATIC
    ${PROJECT_SRC_DIR}/ai_common.cpp
)

# ----------------------
# 头文件管理
# ----------------------
target_include_directories(${AI_COMMON_LIBRARY}
    PUBLIC  # 外部项目包含此路径即可使用库接口
        ${PROJECT_INCLUDE_DIR}
        ${PCL_INCLUDE_DIRS}
)

# 指定公共头文件（用于安装和IDE索引）
set_target_properties(${AI_COMMON_LIBRARY} 
    PROPERTIES
    PUBLIC_HEADER "include/ai_common.h"
)


# ----------------------
# 编译选项
# ----------------------
target_compile_options(${AI_COMMON_LIBRARY} PRIVATE
    $<$<CXX_COMPILER_ID:GNU>:-Wall -Wextra -pedantic>  # GCC警告 -Wno-c++11-long-long
    $<$<CXX_COMPILER_ID:Clang>:-Wall -Wextra -pedantic -Wno-unknown-pragmas>  # Clang警告
    $<$<CXX_COMPILER_ID:AppleClang>:-Wall -Wextra -pedantic -Wno-unknown-pragmas>  # Apple Clang警告
)

# ----------------------
# 依赖链接（静态库内部依赖）
# ----------------------
target_link_libraries(${AI_COMMON_LIBRARY} PRIVATE
)

# ----------------------
# 安装配置（可选，用于打包）
# ----------------------
install(TARGETS ${AI_COMMON_LIBRARY}
    ARCHIVE DESTINATION lib  # 静态库安装路径
    PUBLIC_HEADER DESTINATION include  # 头文件安装路径
)